package com.example.demo.controller.web;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.model.web.Jingdian;
import com.example.demo.repository.web.JingdianRepositoryWeb;

@Controller
@RequestMapping("/web/jingdian")
public class JingdianControllerWeb {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private JingdianRepositoryWeb jingdianRepository;
	
	@RequestMapping("/insert")
	@ResponseBody
	public Object insert() {
		Jingdian jd = new Jingdian();
		jd.setName("天文台");
		jd.setImg("twt.jpg");
		jd.setLocation("#page_map_class1");
		List<String> p = new ArrayList<String>();
		p.add("hah");
		p.add("tets");
		jd.setParagraph(p);
		logger.info(jd.toString());
		return jingdianRepository.save(jd);
	}
	
	@RequestMapping("/findall")
	@ResponseBody
	@CrossOrigin
	public List<Jingdian> findall(){
		return jingdianRepository.findAll();
	}
}
